package com.songminju.jsong_mvc.ioc;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Map;

import com.songminju.jsong_ioc.IOCManagerFactory;
import com.songminju.jsong_ioc.ObjectFilter;
import com.songminju.jsong_mvc.annotation.Controller;
import com.songminju.jsong_mvc.controller.HttpHandler;
import com.songminju.jsong_mvc.ioc.annotation.IocBean;

public class IOCManager {
	
	public void loadFiltersAndControllers(String packStr,HttpHandler hh) {
		com.songminju.jsong_ioc.IOCManager iocManager = IOCManagerFactory.defaultIOCManager();
		iocManager.load(packStr, true, new ObjectFilter<Class<Object>>() {
			
			@Override
			public boolean pattern(Class<Object> t) {
				
				Annotation[] annos = t.getAnnotations();
				for(Annotation anno:annos) {
					if(anno instanceof Controller) {
						return true;
					}
					if(anno instanceof IocBean) {
						return true;
					}
					
				}
				
				return false;
			}
		}, new ObjectFilter<Field>() {

			@Override
			public boolean pattern(Field t) {
				return true;
			}
			
		});
		Map<String,Object> objs = iocManager.getAll();
		
		
	}
}
